﻿using FingerTip.Data.Configuration;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;

namespace FingerTip.Data.Providers
{
    public class MSSQLDataProvider:IDataProvider
    {
        public DataProvider Provider { get; } = DataProvider.MSSQL;
        public IServiceCollection RegisterDbContext(IServiceCollection services,string connectionString)
        {
            services.AddDbContext<FingerTipDbContext>(options => options.UseSqlServer(connectionString));
            return services;
        }

        public FingerTipDbContext CreateDbContext(string connectionString)
        {
            var optionsBuilder = new DbContextOptionsBuilder<FingerTipDbContext>();
            optionsBuilder.UseSqlServer(connectionString);

            return new FingerTipDbContext(optionsBuilder.Options);
        }
    }
}
